set more off
capture log close
capture clear all

/***!***!***!***!***!*** [National_banks_crisis_2018_b.do ] ***!***!***!***!***!
*
* Project: National Banks  		
* Programmer:  Scott Fulford, revised and cleaned up by Felipe Schwartzman
              
*
* Date:    	 Jan 2018
*
* Auditor:      
* Audit Date:   
*
* Purpose:      
* 1) Create graph showing silver/gold ratio
* 2) 
* 3)
* 		      
*
* Ouputs: 
*		
* Sources: silver prices GFD.xlsx 


*
***!***!***!***!***!***!***!***!***!***!***!***!***!***!***!***!***/


/***Define Global Directory ****/
//Change rootdir to where store files
	global ROOTDIR "F:/Dropbox/national banks peg/Replication_files"
	local PROGDIR  "$ROOTDIR"
	local INDIR  "$ROOTDIR/data"
	local OUTDIR  "$ROOTDIR/data"
/*******************************/

cd "`INDIR'"

import excel "`INDIR'\silver prices GFD.xlsx", ///
  sheet("Price Data") firstrow
gen double date= date(Date, "MDY")
format date %td
rename Close silver
keep date silver
tempfile silver
save `silver', replace

import excel "`INDIR'\gold prices GFD.xlsx", ///
  sheet("Price Data") firstrow clear
gen double date= date(Date, "MDY")
rename Close gold
format date %td
keep date gold

merge 1:1 date using `silver'

tsset date
gen gold_silver =gold/silver

format date %tdCCYY //format so only shows year on date


twoway (tsline gold_silver) if date>date("01/01/1889", "MDY") & date<date("01/01/1901", "MDY") , ///
  tlabel(01jan1888 01jan1890 01jan1892 01jan1894 01jan1896 01jan1898 01jan1900 ) ///
  tline(1jul1890 1oct1893 1dec1896 1mar1900, lcolor(gs10)) /// 
  xtitle(Date) ytitle(Price of gold/Price of silver) /// 
  ttext(38 1may1890 "Sherman Silver" "Purchase Act", just(right) placement(w) size(small)) /// 
  ttext(38 1sep1893 "1893" "Panic", just(right) placement(w) size(small)) ///
  ttext(38 1nov1896 "1896" "Election", just(right) placement(w) size(small))  /// 
  ttext(38 1feb1900 "Gold" "Standard" "Act" , just(right) placement(w) size(small)) ///
  ttext(38 1dec1907 "1907" "Panic", just(right) placement(w) size(small)) ///
  name(gold_silver, replace)


  cd "`OUTDIR'"
  graph export gold_silver.pdf,  as(pdf) name(gold_silver) font(times) replace 

exit
